[SPARK-28897][SQL] 'coalesce' error when executing dataframe.na.fill #27392
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Root Cause:
When a dataframe is created using select statement (using spark.sql.parser.quotedRegexColumnNames=true) dataframe fill is called- the fillCol in DataFrameNaFunctions, ``(backtick) are added explicitly to the columnNames, the column name is misunderstood to be a regex and it is set as an unresolvedregex, which makes the coalesce resolving to fail.
Observation
When we create the dataframe from the select statement using a regex, valid columns names are returned after applying the filter(regex). So adding backticks to column name in this flow was not needed. To check the impact, select statement with regex were used, there was no impact while executing without the backticks.
After Fix
While passing the columnname to the dataframe column method, ``(backtick) are not added, as the value that is received is not a regular expression, but a valid column name.
Why are the changes needed?
By doing this change column name is not considered as regex and the proper Column function is
And does not fail to resolve the expression.
Does this PR introduce any user-facing change?
NA
How was this patch tested?
unit test